<?php

namespace App\Http\Requests\Form;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class PmFormAttachmentRequest extends FormRequest
{
    /**
     * 表示验证器是否应在第一个规则失败时停止
     *
     * @var bool
     */
    protected $stopOnFirstFailure = true;

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'title' => 'required|max:64',
            'file_id' => 'required|integer',
        ];
    }

    /**
     * 获取验证错误的自定义属性
     *
     * @return string[]
     */
    public function attributes()
    {
        return [
            'title' => '表单标题',
            'file_id' => '附件信息',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return string[]
     */
    public function messages()
    {
        return [
            'title.required' => '表单名称不能为空',
            'title.max' => '表单名称最长为64个字符',
            'file_id.required' => '附件信息不能为空',
            'file_id.integer' => '附件ID必须为整型',
        ];
    }
}
